﻿using System;

class MaxSequenceOfElements

            // Write a program that finds the maximal sequence of equal elements in an array.
		    // Example: {2, 1, 1, 2, 3, 3, 2, 2, 2, 1}  {2, 2, 2}.

{
    static void Main()
    {
        Console.WriteLine("Enter the length of  the array:");
        int arraySize = int.Parse(Console.ReadLine());
        int[] array = new int[arraySize];
        Console.WriteLine();

        Console.WriteLine("Enter the elements of the array:");
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = int.Parse(Console.ReadLine());
        }
        int start = 0;
        int length = 1;
        int bestStart = 0;
        int bestLength = 0;
        for (int i = 1; i < array.Length; i++)
        {
            if (array[i] == array[i - 1])
            {
                start = i - length;
                length += 1;
                if (length > bestLength)
                    {
                        bestLength = length;
                        bestStart = start;
                    }
            }
            else
            {
                start = 0;
                length = 1;
            }
        }
        Console.WriteLine("The maximal sequence consists of {0} elements with value {1} ", bestLength, array[bestStart]);
    }
}
